package com.sinosoft.vaccinetoai.utils.http;

/**
 * @author xiazhihao
 * @ClassName: UnicodeUtils
 * @ClassNameExplain:
 * @Description: xiazhihao
 * @date 2023/7/31 11:29
 */
public class UnicodeUtils {

    public static String decodeUnicode(String unicode) {
        StringBuilder sb = new StringBuilder();

        int i = -1;
        int pos = 0;

        while ((i = unicode.indexOf("\\u", pos)) != -1) {
            sb.append(unicode.substring(pos, i));
            if (i + 5 < unicode.length()) {
                pos = i + 6;
                sb.append((char) Integer.parseInt(unicode.substring(i + 2, i + 6), 16));
            }
        }

        sb.append(unicode.substring(pos));

        return sb.toString();
    }
}

